﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ImageDemo.PictureBoxDemo
{
    public partial class PictureMoveByMouse : Form
    {
        public PictureMoveByMouse()
        {
            InitializeComponent();
        }

        private void PictureMoveByMouse_Load(object sender, EventArgs e)
        {
            pbMove.SizeMode = PictureBoxSizeMode.AutoSize;
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            string strTemp = strBasePath.Substring(0, strBasePath.IndexOf(@"demo\"));
            string imgPath = strTemp + @"demo\data\head.jpg";
            pbMove.ImageLocation = imgPath;
            pbMove.Load();
        }

        private void pbMove_DragDrop(object sender, DragEventArgs e)
        {
            PictureBox pbTemp = sender as PictureBox;
            if (pbTemp == null)
            {
                return;
            }
            if (e.Effect != DragDropEffects.Move)
            {
                return;
            }
            pbTemp.Location = new Point(e.X, e.Y);
        }
    }
}
